/**
 * 发送心跳
 */
var heartTimeout;
function sendHeart(){

    var heartStr = new Object();
    heartStr.id = "ack";
    heartStr.name = "1";
    sendMessage(heartStr);

    heartTimeout = setTimeout(function(){

        //递归发送心跳
        sendHeart();

    }, 1000 * 10);
}

/**
 * 如果断开连接
 */
function wsClose(){
    //关闭心跳
    clearTimeout(heartTimeout);

    //开始重连
    setTimeout(function(){
        //开始重连
        reConnectWs();
    }, 1000 * 10);
}

function reConnectWs(){
    console.log("开始重连......" + data.url)
    ws.close();
    // ws = new WebSocket('ws://' + location.host + '/call');
    // ws = new WebSocket(data.url);
    initWsRtc(data);
    setRegisterState(NOT_REGISTERED);
}